package com.kantboot.business.gc.repository;

import com.kantboot.business.gc.domain.dto.BusGcTypeSearchDTO;
import com.kantboot.business.gc.domain.entity.BusGcType;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface BusGcTypeRepository extends JpaRepository<BusGcType,Long> {


    @Query("""
    FROM BusGcType a
    WHERE
    (:#{#param.zhName} IS NULL OR :#{#param.zhName} = '' OR a.zhName like %:#{#param.zhName}%)
    AND (:#{#param.enName} IS NULL OR :#{#param.enName} = '' OR a.enName like %:#{#param.enName}%)
    AND (:#{#param.zhDescription} IS NULL OR :#{#param.zhDescription} = '' OR a.zhDescription like %:#{#param.zhDescription}%)
    AND (:#{#param.enDescription} IS NULL OR :#{#param.enDescription} = '' OR a.enDescription like %:#{#param.enDescription}%)
    ORDER BY a.priority DESC
    """)
    Page<BusGcType> getBodyData(@Param("param") BusGcTypeSearchDTO param, Pageable pageable);

}
